<!DOCTYPE html>
<html>
<head>
    <meta name="layout" content="main"/>
    <g:set var="entityName" value="${message(code: 'contract.label', default: 'Contract')}"/>
    <title>编辑贷款合同</title>
</head>

<body>
<div class="small-header">
    <div class="hpanel">
        <div class="panel-body">
            <div id="hbreadcrumb" class="pull-right">
                <ol class="hbreadcrumb breadcrumb">
                    <li>PLS CINDATA</li>
                    <li>
                        <g:link controller="menu" action="index">CINDATA</g:link>
                    </li>
                    <li class="active">
                        <span>编辑贷款合同</span>
                    </li>
                </ol>
            </div>

            <h2 class="font-light m-b-xs">
                编辑贷款合同
            </h2>
        </div>
    </div>
</div>

<g:form action="updateContract">
    <g:if test="${flash.message}">
        <div class="message alert alert-info" role="status">${flash.message}</div>
    </g:if>
    <g:hasErrors bean="${this.menu}">
        <ul class="errors" role="alert">
            <g:eachError bean="${this.menu}" var="error">
                <li <g:if test="${error in org.springframework.validation.FieldError}">data-field-id="${error.field}"</g:if>><g:message
                        error="${error}"/></li>
            </g:eachError>
        </ul>
    </g:hasErrors>

    <g:hiddenField name="mortgageId" value="${params['mortgageId']}"/>
    <g:hiddenField name="id" value="${contract?.id}"/>
    <div class="content animate-panel">
        <div class="row">
            <div class="hpanel hblue">
                <div class="panel-heading">
                    基本信息
                </div>

                <div class="panel-body form-horizontal">

                    <div class="form-group">
                        <label class="col-md-2 control-label ">合同类型</label>
                        <div class="col-md-3">
                            <g:select class="form-control m-b" name="type" id="type" from="${com.cindata.dictionary.ContractType.list()}" optionValue="name" optionKey="id" value="${contract?.type?.id}" noSelection="${['': '请选择合同类型']}"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label ">合同编号</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="contractNumber" id="contractNumber" value="${contract?.contractNumber}"/>
                        </div>

                        <label class="col-md-2 control-label ">担保人</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="guarantee" id="guarantee" value="${contract?.guarantee}"/>
                        </div>


                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label ">合同签订日期</label>
                        <div class="col-md-3">
                            <g:datePicker class="form-control" name="contractSignDate" value="${contract?.contractSignDate}" precision="minute"/>
                        </div>

                        <label class="col-md-2 control-label ">质押权人/债权人</label>
                        <div class="col-md-3">
                            <g:select class="form-control m-b" name="contact" id="contact" from="${com.cindata.Contact.list(max:1000,offset: 0)}" optionValue="fullName" optionKey="id" value="${contract?.contact?.id}" noSelection="${['': '请选择质押权人']}"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label ">出质人/债务人</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="pledgor" id="pledgor" value="${contract?.pledgor}"/>
                        </div>

                        <label class="col-md-2 control-label ">借款人类型</label>
                        <div class="col-md-3">
                            <g:select class="form-control m-b" name="borrowerType" id="borrowerType" from="${com.cindata.dictionary.BorrowerTypeDict.list()}" optionValue="name" optionKey="id" value="${contract?.borrowerType?.id}" noSelection="${['': '请选择借款人类型']}"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label ">借款人单位</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="borrowerCompany" name="borrowerCompany" id="cltv" value="${contract?.borrowerType}"/>
                        </div>

                        <label class="col-md-2 control-label ">银行账号</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="bankNumber" id="bankNumber" value="${contract?.bankNumber}"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label ">开户地址</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="openAddress" id="openAddress" value="${contract?.openAddress}"/>
                        </div>

                        <label class="col-md-2 control-label ">联系人</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="linkMan" id="linkMan" value="${contract?.linkMan}"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label ">手机</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="telePhone" id="telePhone" value="${contract?.telePhone}"/>
                        </div>

                        <label class="col-md-2 control-label ">开户行</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="openBank" id="openBank" value="${contract?.openBank}"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label ">开始日期</label>
                        <div class="col-md-3">
                            <g:datePicker class="form-control" name="startDate" value="${contract?.startDate}" precision="minute"/>
                        </div>

                        <label class="col-md-2 control-label ">贷款期限</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="loansDuration" id="loansAmount" value="${contract?.loansDuration}"/>

                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label ">到期日期</label>
                        <div class="col-md-3">
                            <g:datePicker class="form-control" name="endDate" value="${contract?.endDate}" precision="minute"/>
                        </div>

                        <label class="col-md-2 control-label ">贷款金额</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="loansAmount" id="loansAmount" value="${contract?.loansAmount}"/>
                        </div>
                    </div>

                    <div class="form-group">

                        <label class="col-md-2 control-label ">贷款用途</label>
                        <div class="col-md-3">
                            <g:select class="form-control m-b" name="loansUse" id="loansUse" from="${com.cindata.dictionary.LoansUseDict.list()}" optionValue="name" optionKey="id" value="${contract?.loansUse?.id}" noSelection="${['': '请选择贷款用途']}"/>
                        </div>

                        <label class="col-md-2 control-label ">签约地址</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="signAddress" id="signAddress" value="${contract?.signAddress}"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label ">付息方式</label>
                        <div class="col-md-3">
                            <g:select class="form-control m-b" name="payInterestType" id="payInterestType" from="${com.cindata.dictionary.PayInterestTypeDict.list()}" optionValue="name" optionKey="id" value="${contract?.payInterestType?.id}" noSelection="${['': '请选择付息方式']}"/>
                        </div>

                        <label class="col-md-2 control-label ">贷款年利率</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="loanAnnualInterestYearRate" id="loanAnnualInterestYearRate" value="${contract?.loanAnnualInterestYearRate}"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label ">逾期日利率</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="overdueInterestDayRate" id="overdueInterestDayRate" value="${contract?.overdueInterestDayRate}"/>
                        </div>
                        <label class="col-md-2 control-label ">抵质押内容</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="collateralContent" id="collateralContent" value="${contract?.collateralContent}"/>
                        </div>

                    </div>


                    <div class="form-group">
                        <div class="col-md-3 col-md-offset-6">
                            <g:submitButton class="btn btn-info" name="create" value="保存"/>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>



</g:form>

<g:javascript>
    $(function () {
        $('.datepicker').datepicker({
            language: 'zh-CN',
            format:"yyyy-mm-dd"
        });
        $('.input-group.date').datepicker({ });
        $('.input-daterange').datepicker({ });
    });

    // $("#city").bind("change", function(){
    //     $("#district option").remove();
    //     $("#s2id_district span:first").html("请选择行政区");
    //     var city = $("#city").val()
    //     $("#district").append("<option value='-1' >请选择行政区</option>")
    //     if(city=='-1'){
    //         return
    //     }
    //     $.ajax({
    //         url: "/estate/districtList",
    //         type: "POST",
    //         data: {'city': city} ,
    //         success: function(result){
    //             for(var i=0; i < result.districtList.length; i++){
    //                 $("#district").append("<option value=" + result.districtList[i].zoneNumber + ">" + result.districtList[i].name + "</option>")
    //             }
    //         }
    //     });
    // });
    // $("#city").change();

</g:javascript>
</body>
</html>
